﻿<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="NLBS.Entity" assembly="NLBS.Entity">
  <class name="User" table="blog_User">
    <id name="UserID" column="user_id" type="Int32">
      <generator class="native" />
    </id>
    <property name="UserName" column="user_name" type="String" />
    <property name="Password" column="user_password" type="String" />
    <property name="Salt" column="user_salt" type="String" />
    <property name="GroupID" column="user_groupID" type="Int32" />
    <property name="Gender" column="user_gender" type="Int32" />
    <property name="Email" column="user_email" type="String" />
    <property name="HideEmail" column="user_hideEmail" type="Boolean" />
    <property name="Homepage" column="user_homepage" type="String" not-null="true" />
    <property name="ArticleCount" column="user_articleCount" type="Int32" />
    <property name="CommentCount" column="user_commentCount" type="Int32" />
    <property name="LastVisit" column="user_lastVisit" type="DateTime" />
    <property name="IP" column="user_ip" type="String" />
    <property name="HashKey" column="user_hashKey" type="String" />

    <!--<one-to-one name="Address" class="Address" cascade="save-update"/>-->

    <many-to-one name="Group" class="UserGroup" update="false"
             insert="false"
             not-found="ignore" column="user_groupID"/>
    
    <bag name="Articles">
      <key column="log_authorID" />
      <one-to-many class="Article"/>
    </bag>

    <bag name="Comments">
      <key column="comm_authorID"/>
      <one-to-many class="Comment" not-found="ignore"/>
    </bag>
    
  </class>

  <class name="Address" table="blog_UserAddress">
    <id name="AddressId" column="AddressId" type="Int32">
      <generator class="foreign">
        <param name="property">user</param>
      </generator>
    </id>
    <one-to-one name="user" class="User" constrained="true"/>
    <property name="Phone" column="user_phone" type="String" />
   
  </class>
</hibernate-mapping>
